package com.ruoyi.cms.controller;

import com.ruoyi.cms.domain.CmsSchoolInfo;
import com.ruoyi.cms.service.ICmsSchoolInfoService;
import com.ruoyi.common.core.web.controller.BaseController;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.common.core.web.page.TableDataInfo;
import com.ruoyi.common.log.annotation.Log;
import com.ruoyi.common.log.enums.BusinessType;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 学校信息Controller
 *
 * @author houyong
 * @date 2025-11-08
 */
@Tag(name = "CmsSchoolInfoController", description = "学校信息管理for管理后台")
@RestController
@RequestMapping("cms/manager/info")
public class CmsSchoolInfoController extends BaseController {
    @Autowired
    private ICmsSchoolInfoService cmsSchoolInfoService;

    /**
     * 查询学校信息列表
     */
//    @RequiresPermissions("system:info:list")
    @GetMapping("/list")
    public TableDataInfo list(CmsSchoolInfo cmsSchoolInfo) {
        startPage();
        List<CmsSchoolInfo> list = cmsSchoolInfoService.selectCmsSchoolInfoList(cmsSchoolInfo);
        return getDataTable(list);
    }


    /**
     * 获取学校信息详细信息
     */
//    @RequiresPermissions("system:info:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") String id) {
        return success(cmsSchoolInfoService.selectCmsSchoolInfoById(id));
    }

    /**
     * 新增学校信息
     */
//    @RequiresPermissions("system:info:add")
    @Log(title = "新增学校信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmsSchoolInfo cmsSchoolInfo) {
        return toAjax(cmsSchoolInfoService.insertCmsSchoolInfo(cmsSchoolInfo));
    }

    /**
     * 修改学校信息
     */
//    @RequiresPermissions("system:info:edit")
    @Log(title = "编辑学校信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmsSchoolInfo cmsSchoolInfo) {
        return toAjax(cmsSchoolInfoService.updateCmsSchoolInfo(cmsSchoolInfo));
    }

    /**
     * 删除学校信息
     */
//    @RequiresPermissions("system:info:remove")
    @Log(title = "删除学校信息", businessType = BusinessType.DELETE)
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable String[] ids) {
        return toAjax(cmsSchoolInfoService.deleteCmsSchoolInfoByIds(ids));
    }
}
